function myPromiseAll(arr = []) {
    let p = new Promise((resolve, reject) => {
        let arrResult = []
        for (let index = 0; index < arr.length; index++) {
            arr[index].then((data) => {
                arrResult.push(data);
                if(arrResult.length==arr.length){
                    resolve(arrResult);
                }
            }).catch((err)=>{
                reject(err);
            })
        }
    })
    return p;
}

const promise1 = new Promise(resolve => resolve(1));

const promise2 = new Promise(resolve => resolve(2));

const promise3 = new Promise(resolve => resolve(3));

const promiseAll = myPromiseAll([promise1, promise2, promise3]);

promiseAll.then(function(res) {

  console.log(res); // 输出：[1,2,3]

});
